<%- include header %>
<!-- 主题内容start -->
<table class="table table-bordered table-striped table-condensed table-hover">
    <tr>
        <th class="span3" colspan="7"><h4 style="text-align: center">活动(活动总数：<%- count %>个|当前页：<%- page.num %>/<%- page.pageCount %>页)</h4></th>
    </tr>
    <tr>
        <th class="span3">主题</th>
        <th class="span3">活动时间</th>
        <th class="span2">活动详情</th>
        <th class="span2">参与人数</th>
        <th class="span2">发布用户</th>
        <th class="span2">审核结果</th>
        <th class="span2">操作</th>
    </tr>
    <% datas.forEach(function(data,index){ %>
    <tr>
        <td>
            <%- data.theme %>
        </td>
        <td>
            <%- data.activeDate %>
        </td>
        <td>
            <a id="t<%- data._id %>">活动详情</a>
            <div id="win<%- data._id %>" iconCls="icon-save" >

                <div style="background-color: white;border: 1px solid #ffffff;-moz-border-radius: 10px;-webkit-border-radius: 10px;margin-top: 20px;padding: 2%">
                    <div style="width: 200px;height:250px;float: left;border: 1px dotted #9f9d93;">
                        <img id="img_poster"  src="<%-data.poster%>" style="width: 200px;height: 250px">
                    </div>
                    <div style="float: left;width: 50%;margin-left: 20px">
                        <div style="font-size: large">

                            <h3 style="color: #797979"><b>活动名称：<%- data.theme %></b></h3>
                            <h4><b style="color:#9e9e9e">活动时间：<%-data.activeDate %></b></h4>
                            <h4><b style="color:#9e9e9e">活动地点：<%-data.addr %></b></h4>
                            <h4><b style="color:#9e9e9e">主办方：<%-data.sponsor %></b></h4>
                            <h4><b style="color:#9e9e9e">语言：<%-data.language %></b></h4>
                            <h4><b style="color:#9e9e9e">费用：￥ <%-data.cost %></b></h4>
                        </div>

                    </div>
                    <div style="clear: both"></div>
                    <div style="-webkit-border-radius:10px 10px 0px 0px;clear: both;background: #fd9b05;height: 40px;text-align: center;width: 30%;margin-top: 20px">
                        <h3 style="color: #9e9e9e"><b>活动详情</b></h3>
                    </div>
                    <div style="word-wrap:break-word;height: 200px;background: #f2f2f2;-webkit-border-radius:0px 10px 10px 10px;padding: 20px">
                        <b style="color: #767676;font-size: 18px"><%- data.discribe %></b>
                    </div>
                </div>
            </div>
        </td>
        <td>
            <a href="/manager/applyUsers?id=<%- data._id %>"><span><%- data.applyNum %>人(点击查看详情)</span>
        </td>
        <td>
            <span><%- data.user.username %></span>
        </td>
        <td>
           <% if(data.state==0){%>
                <span>未处理</span>
            <% }if(data.state==1){%>
                <span style="color: #00d100">已通过</span>
            <% }if(data.state==2){%>
                <span style="color: #ff0000">已拒绝</span>
            <%}%>
        </td>
        <td>
            <a class="btn btn-danger btn-small" onclick="updateState('<%- data._id %>',1)">通过</a>
            <a class="btn btn-info btn-small" onclick="updateState('<%- data._id %>',2)">拒绝</a>
        </td>
    </tr>

    <script>
        $('#win<%- data._id %>').window({
            title: '菜单',
            width: 900,
            modal: true,
            shadow: true,
            closed: true,
            maximizable : false,
            height: 450,
            resizable:true
        });

        $("#t<%- data._id %>").click(function(){

            $('#win<%- data._id %>').window('open');
        })

    </script>
    <% }) %>
</table>

<hr>

<div class="span12">
    <div id="page1"></div>
</div>
<!-- 主题内容end -->
<%- include footer %>
<script>
    function updateState(id,state){
        var prompt=confirm("你确定执行操作码？？");

        if(prompt){

            window.location.href="/manager/updateActiveState?id="+id+"&state="+state;
        }
    }
    function goDelete(id){
        var prompt=confirm("你确定删除该活动吗？？");

        if(prompt){

            window.location.href="/manager/delActive?id="+id;
        }
    }
    $(function(){
        //获得浏览器参数

        $.extend({
            getUrlVars: function(){
                var vars = [];
                var hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                console.log(hashes);
                for(var i = 0; i < hashes.length; i++){
                    hash = hashes[i].split('=');
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
                return vars;
            },
            getUrlVar: function(name){
                return $.getUrlVars()[name];
            }
        });

        //封装浏览器参数
        var composeUrlParams=function(){
            var param='';
            $.each($.getUrlVars(), function(i, item) {
                if(item!='num'){
                    var val=$.getUrlVar(item);
                    if(val) param += "&" + item+"="+val;
                }
            });
            return param;
        }
        var options = {
            currentPage:<%- page.num %>,                //当前页，css样式同其他页不同
            totalPages:<%- page.pageCount %>,           //总页数
            numberOfPages:5,                            //导航最多显示页数
            pageUrl: function(type, page, current) {    //页面跳转
                if(page!=<%- page.num %>){
                    return "/manager/userActive?num="+ page+composeUrlParams();
                }

            }
        }
        $('#page1').bootstrapPaginator(options);
    })

</script>



